package com.maxverse.boot.web2image.screenshot.config;

import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import java.util.HashMap;
import java.util.Map;

@Data
@Configuration
@ConfigurationProperties(prefix = "playwright")
public class PlaywrightConfig {
    private Browser browser = new Browser();
    private Screenshot screenshot = new Screenshot();

    @Data
    public static class Browser {
        private int poolSize = 5;
        private LaunchOptions launchOptions = new LaunchOptions();
        private int maxRetries = 3;
        private int retryDelay = 2000; // ms
    }

    @Data
    public static class LaunchOptions {
        private boolean headless = true;
        private Map<String, String> args = new HashMap<>();
        
        public LaunchOptions() {
            // 添加一些默认的浏览器参数
            args.put("--disable-web-security", "");
            args.put("--no-sandbox", "");
            args.put("--disable-setuid-sandbox", "");
            args.put("--disable-dev-shm-usage", "");
        }
    }

    @Data
    public static class Screenshot {
        private int defaultTimeout = 30000;
        private int defaultWidth = 1920;
        private int defaultHeight = 1080;
    }
} 